package team.hyznrj.studentsys.entity;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;

import com.gemstone.gemfire.internal.tools.gfsh.app.commands.value;

import lombok.Data;
import team.hyznrj.studentsys.utils.ValueUtil;

@Data
public class ExcelStaticParam {
	/**
	 * 日期FORMAT:yyyy-MM-dd
	 */
	private  SimpleDateFormat  DATE_FORMAT=new SimpleDateFormat("yyyy-MM-dd");
	/**
	 * 分数是否需要除以2
	 */
	private  boolean DIV_TWO=false;
	/**
	 * 组织管理分是否需要除
	 */
	private  boolean DIV_ORIGINATION=false;
	/**
	 * EXCEL的静态长度(23),不包括科目一项
	 */
	private  int EXCEL_STATIC_LENGTH=23;
	
	/**
	 * 显示在EXCEL上的科目超过总人数的比率
	 */
	private  double EXCEL_SUBJECT_SELECTIVE=0.8;
	
	/**
	 * 专业文化素质占分比
	 */
	private  double EXCEL_AVG_CULTURE_GRADE=0.7;
	/**
	 * 专业文化素质(没有体育课的)占分比
	 */
	private  double EXCEL_AVG_CULTURE_GRADE_WITHOUT_PE=0.75;
	
	/**
	 * 思想道德分比率
	 */
	private  double EXCEL_MORALITY_RATE=0.15;
	
	/**
	 * 思想道德加分上限
	 */
	//思想政治//默认是2：2
	private  double MORALITY_MAX_ADD1=4;
	//道德品质
	private  double MORALITY_MAX_ADD2=2;
	/**
	 * 思想道德扣分上限
	 */
	private  double MORALITY_MAX_DEC=6;
	/**
	 * 道德素质基本分
	 */
	private  double EXCEL_BASE_MORALITY=11.0;
	/**
	 * 身体素质分比率
	 */
	private  double EXCEL_PE_RATE=0.05;
	/**
	 * 社会实践能力比率
	 */
	private  double EXCEL_PARTICE_RATE=0.10;
	/**
	 * 科技创新分最高分
	 */
	private  double PARTICE_MAX_INNOVATION=4;
	/**
	 * 技术技能分最高分
	 */
	private  double PARTICE_MAX_SKILL=4;
	/**
	 * 组织管理能力最高分
	 */
	private  double PARTICE_MAX_ORGINATION=2;
	/**
	 * 特殊加分最高分
	 */
	private  double PARTICE_MAX_SPECIAL=4;
	/**
	 * 保留2位小数点
	 */
	private  DecimalFormat format=new DecimalFormat("0.00");
	/**
	 * 保留0位小数点
	 */
	private  DecimalFormat formatWithZero=new DecimalFormat("0");
	private  DecimalFormat formatWithFourth=new DecimalFormat("0.0000");
	/**
	 * 奖学金占全班比例(必须在前30%内)
	 */
	private  double REWARD_RATE_IN_CLASS_PERCENT=0.3;
	/**
	 * 一等奖、二等奖条件:
	 * 获一、二等奖学金的学生，综合测评在班前15%名以内，学业平均成绩在80分（平均绩点3）以上。
	 * 获三等奖学金的学生，综合得分应在全班前35%名以内，学业成绩平均在75分以上。
	 */
	private  double REWARD_RATE_IN_FIRST_REWARD=0.15;
	private  double REWARD_RATE_IN_FIRST_REWARD_IN_AVG_GRADE=3.0;
	
	private  double REWARD_RATE_IN_SECOND_REWARD=0.15;
	private  double REWARD_RATE_IN_SECOND_REWARD_IN_AVG_GRADE=3.0;
	
	private  double REWARD_RATE_IN_THIRD_REWARD=0.35;
	private  double REWARD_RATE_IN_THIRD_REWARD_IN_AVG_GRADE=2.5;
	/**
	 * 一等奖数量 //TODO 默认不超过3% 7% 20%
	 */
	private  int FIRST_REWARD_NUM=-1;
	private  double FIRST_REWAR_NUMBER_RATE=0.03;

	/**
	 * 二等奖数量
	 */
	private  int SECOND_REWARD_NUM=-1;
	private  double SECOND_REWARD_NUMBER_RATE=0.07;
	/**
	 * 三等奖数量
	 */
	private  int THIRD_REWARD_NUM=-1;
	private  double THIRD_REWARD_NUMBER_RATE=0.20;
	/**奖学金数量是否四舍五入*/
	private boolean ROUNDING=true;
	/**
	 * 是否计算重修成绩
	 */
	private boolean isCountReTake=false;
	/**
	 * 是否计算补考成绩
	 */
	private boolean isCountReExam=false;
	
	int [] staticRewardNumber=new int[3];
	double [] rewarNumberRate=new double[3];
	{
		staticRewardNumber[0]=FIRST_REWARD_NUM;
		staticRewardNumber[1]=SECOND_REWARD_NUM;
		staticRewardNumber[2]=THIRD_REWARD_NUM;
		rewarNumberRate[0]=FIRST_REWAR_NUMBER_RATE;
		rewarNumberRate[1]=SECOND_REWARD_NUMBER_RATE;
		rewarNumberRate[2]=THIRD_REWARD_NUMBER_RATE;
	}
	//获取一等奖的数量,规则:FIRST_REWARD_NUM和FIRST_REWAR_NUMBER_RATE中取大者
	public int getLeastRewardNumber(int level,int classMainCount){
		if(level>3){
			return -1;
		}
		System.err.println(rewarNumberRate[level-1]);
		System.err.println(rewarNumberRate[level-1]*classMainCount);
		System.err.println(ValueUtil.getIntByDouble(rewarNumberRate[level-1]*classMainCount,ROUNDING));
		return ValueUtil.getBiggerInteger(staticRewardNumber[level-1],ValueUtil.getIntByDouble(rewarNumberRate[level-1]*classMainCount,ROUNDING));
	}
	private double[] orginationList={2.0,1.6,1.5,1.3,1.0,0};
	/**
	 * 获取最近的数据
	 * @param e
	 * @return
	 */
	public double getClosestNumber(Double e){
		if(e==null){
			return 0.0;
		}
		for(int i=0;i<orginationList.length;i++){
			//如果等于该数组的数据，则返回
			if(e==orginationList[i]){
				return e;
			}
			if(e>orginationList[i]){
				return orginationList[i];
			}
		}
		return 0.0;
	}
}
